"""
Author        yongfa
Date          2023-08-31 03:37:19
LastEditTime  2023-09-07 09:49:31
LastEditors   yongfa
Description   参数校验
"""

from flask_restx import reqparse, inputs
from werkzeug.datastructures import FileStorage
from app.extensions.utils.enums import ResumeEmailProtocolEnum, ResumeEmailParserTypeEnum

from app.extensions.utils.parameters import page_params

# EmailInfo
get_list_params = page_params.copy()
get_list_params.add_argument('company_id', type=int, location='args', trim=True, help='公司ID')
get_list_params.add_argument('email', type=str, location='args', trim=True, help='邮箱')
get_list_params.add_argument('status', type=inputs.boolean, location='args', help='邮箱状态')


update_params = reqparse.RequestParser()
update_params.add_argument('status', type=inputs.boolean, location='json', trim=True, help='状态')


# ResumeEmailTask
get_list_ret_params = page_params.copy()
get_list_ret_params.add_argument('company_id', type=int, location='args', help='公司ID')
get_list_ret_params.add_argument('company_email_id', type=int, location='args', help='公司邮箱ID')
get_list_ret_params.add_argument('status', type=int, location='args', trim=True, help='状态')

create_ret_params = reqparse.RequestParser()
create_ret_params.add_argument('email', type=str, required=True, location='json', trim=True, help='邮箱号码')
create_ret_params.add_argument('email_host', type=str, required=True, location='json', trim=True, help='邮箱服务器地址')
create_ret_params.add_argument('email_protocol', type=str, required=True, choices=ResumeEmailProtocolEnum.list_values(),
                               location='json', trim=True, help='邮箱登录协议')
create_ret_params.add_argument('email_port', type=int, location='json', trim=True, help='邮箱端口')
create_ret_params.add_argument('email_password', type=str, required=True, location='json',
                               trim=True, help='邮箱密码')
create_ret_params.add_argument('email_ssl', type=inputs.boolean, required=True,
                               location='json', trim=True, help='邮箱SSL')
create_ret_params.add_argument('filter_conditions', type=dict, location='json', trim=True, help='过滤条件')
create_ret_params.add_argument('callback_url', type=str, location='json', trim=True, help='回调地址')


# ResumeEmail
get_list_re_params = page_params.copy()
get_list_re_params.add_argument('email_info_id', type=int, location='args', trim=True, help='公司ID')
get_list_re_params.add_argument('email_from', type=str, location='args', trim=True, help='邮件发送人')
get_list_re_params.add_argument('email_from_name', type=str, location='args', trim=True, help='邮件发送人姓名')
get_list_re_params.add_argument('mail_subject', type=str, location='args', trim=True, help='邮件主题')
get_list_re_params.add_argument('status', type=int, location='args', trim=True, help='邮件处理状态')


# ResumeParserTask
get_list_rpt_params = page_params.copy()
get_list_rpt_params.add_argument('company_id', type=int, location='args', help='公司ID')
get_list_rpt_params.add_argument('email_info_id', type=int, location='args', help='邮箱ID')
get_list_rpt_params.add_argument('resume_email_id', type=int, location='args', trim=True, help='邮件ID')
get_list_rpt_params.add_argument('status', type=int, location='args', trim=True, help='邮件处理状态')

create_rpt_params = reqparse.RequestParser()
create_rpt_params.add_argument('resume_type', type=int, required=True, choices=ResumeEmailParserTypeEnum.list_values(),
                               location='json', help='解析类型: 0: 文本 1: 文件')
create_rpt_params.add_argument('resume_text', type=str, required=True, location='json', help='解析文本')
create_rpt_params.add_argument('file', type=FileStorage, location='json', help='解析文件')  # 目前有问题
create_rpt_params.add_argument('callback_url', type=str, location='json', help='结果回调地址')


# ResumeContent
get_list_rc_params = page_params.copy()
get_list_rc_params.add_argument('company_id', type=int, location='args', help='公司ID')
get_list_rc_params.add_argument('email_info_id', type=int, location='args', help='邮箱ID')
get_list_rc_params.add_argument('resume_email_id', type=int, location='args', trim=True, help='邮件ID')

set_params = {
    'get_list_params': get_list_params,
    'update_params': update_params,
    'get_list_ret_params': get_list_ret_params,
    'create_ret_params': create_ret_params,
    'get_list_re_params': get_list_re_params,
    'get_list_rpt_params': get_list_rpt_params,
    'create_rpt_params': create_rpt_params,
    'get_list_rc_params': get_list_rc_params,

}
